<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script type="text/javascript">
    let url = "http://47.106.187.222/plan/dictParent"


    let xhr = new XMLHttpRequest();
    xhr.onreadystatechange = function () {
        if (xhr.readyState == 4) {
            if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304) {
                console.log(xhr.responseText);
            } else {
                console.log("Request was unsuccessful: " + xhr.status);
            }
        }
    };
    url = addURLParam(url, "name", 'jack');
    url = addURLParam(url,'age',12)
    xhr.open("get", url, true);
    xhr.setRequestHeader("MyHeader", "MyValue");
    xhr.send(null);

    /*
        可以使用以下函数来封装
     */
    function addURLParam(url='', name, value) {
        url += (url.indexOf("?") == -1 ? "?" : "&");
        url += encodeURIComponent(name) + "=" + encodeURIComponent(value);
        return url;
    }
</script>
</body>
</html>